<template>
	<div>
		<el-form ref="form" :model="form" label-width="100px">

			<!-- <el-form-item label="序号" prop="nId">
				<el-input v-model="form.nId"></el-input>
			</el-form-item> -->
			<el-form-item label="编号" prop="number">
				<el-input v-model="form.number"></el-input>
			</el-form-item>

			<el-form-item label="名称" prop="name">
				<el-input v-model="form.name"></el-input>
			</el-form-item>
			
			<el-form-item label="价格" prop="price">
				<el-input v-model="form.price"></el-input>
			</el-form-item>

			<el-form-item label="是否增值服务" prop="serve">
				<el-select v-model="form.serve" placeholder="请选择状态" clearable :style="{width: '100%'}">
					<el-option v-for="(item, index) in serveData" :key="index" :label="item.label" :value="item.value"
						:disabled="item.disabled"></el-option>
				</el-select>
			</el-form-item>

			<el-form-item label="状态" prop="status">
				<el-select v-model="form.status" placeholder="请选择状态" clearable :style="{width: '100%'}">
					<el-option v-for="(item, index) in statusData" :key="index" :label="item.label" :value="item.value"
						:disabled="item.disabled"></el-option>
				</el-select>
			</el-form-item>
			
			<el-form-item label="护理级别" prop="level">
				<el-select v-model="form.level">
					<el-option v-for="item in nurclass" :key="item.nclass" :value="item.nclass" :label="item.nclass"></el-option>
				</el-select>
			</el-form-item>
			
			<el-form-item label="备注" prop="note">
				<el-input v-model="form.note"></el-input>
			</el-form-item>
			
			
			<el-form-item>
				<el-button type="primary" @click="save">保存</el-button>
			</el-form-item>
		</el-form>

	</div>
</template>

<script>
	export default {
		name: 'nContentEdit',
		components: {

		},
		props: [
			'showEdit',
			'nid',
			'editid'
		],
		data() {
			return {
				form: {
					nId: '',
					number: '',
					name: '',
					price: '',
					serve: '',
					status: '',
					level:'',
					note:''

				},
				statusData: [{
					"label": "启用",
					"value": "启用"
				}, {
					"label": "不启用",
					"value": "不启用"
				}],
				serveData: [{
					"label": "是",
					"value": "是"
				}, {
					"label": "否",
					"value": "否"
				}],
				url: '/nContent/save',
				depts: [],
				nurclass:[],
			}
		},
		created() {
			this.init()
			console.log("this.editid:" + this.editid)
			if (this.editid) {

				this.axios.get('/nContent/toedit', response => {
					console.log(response);
					console.log(response.obj.nid);
					this.form.nId = response.obj.nid
					this.form.name = response.obj.name
					this.form.number = response.obj.number
					this.form.price = response.obj.price
					this.form.serve = response.obj.serve
					this.form.status = response.obj.status
					this.form.level=response.obj.level
					this.form.note = response.obj.note


				}, {
					nId: this.editid
				})
			}
		},
		methods: {
				save() {
					this.$refs['form'].validate((valid) => {
						if (valid) {
							this.axios.post(this.url, response => {
								// 子组件要改变父组件的值
								this.$emit('update:show', false)
								this.$emit('getData')
							}, this.form)
						}
					})
				},
				init() {
					
					this.axios.get('/user/nclass', response => {
						this.nurclass = response.obj
					})
		
				}
		
			}
		}
</script>

<style>
</style>
